package com.chartboost.sdk.impl;

import android.content.Context;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout.LayoutParams;
import com.chartboost.sdk.Chartboost;
import com.chartboost.sdk.Libraries.CBOrientation;
import com.chartboost.sdk.Libraries.a.a;
import com.chartboost.sdk.Libraries.d;
import com.chartboost.sdk.Libraries.e.b;
import com.chartboost.sdk.b.b;
import com.chartboost.sdk.b.c;
import org.json.JSONObject;

public class b extends com.chartboost.sdk.b
{
  public a.a h = null;
  public a.a i = null;
  public a.a j = null;
  public a.a k = null;
  public a.a l = null;

  public b(a parama)
  {
    super(parama);
    this.e = 5;
  }

  protected b.b a(Context paramContext)
  {
    return new a(paramContext, null);
  }

  public void a(JSONObject paramJSONObject)
  {
    super.a(paramJSONObject);
    e.b local1 = new e.b()
    {
      public void a(a.a paramAnonymousa, Bundle paramAnonymousBundle)
      {
        b.this.i = paramAnonymousa;
        b.a(b.this, paramAnonymousa);
      }
    };
    e.b local2 = new e.b()
    {
      public void a(a.a paramAnonymousa, Bundle paramAnonymousBundle)
      {
        b.this.h = paramAnonymousa;
        b.a(b.this, paramAnonymousa);
      }
    };
    e.b local3 = new e.b()
    {
      public void a(a.a paramAnonymousa, Bundle paramAnonymousBundle)
      {
        b.this.k = paramAnonymousa;
        b.a(b.this, paramAnonymousa);
      }
    };
    e.b local4 = new e.b()
    {
      public void a(a.a paramAnonymousa, Bundle paramAnonymousBundle)
      {
        b.this.j = paramAnonymousa;
        b.a(b.this, paramAnonymousa);
      }
    };
    e.b local5 = new e.b()
    {
      public void a(a.a paramAnonymousa, Bundle paramAnonymousBundle)
      {
        b.this.l = paramAnonymousa;
        b.a(b.this, paramAnonymousa);
      }
    };
    a("ad-landscape", local1, true);
    a("ad-portrait", local2, true);
    a("frame-landscape", local3);
    a("frame-portrait", local4);
    a("close", local5);
  }

  public void c()
  {
    super.c();
    if (this.i != null)
    {
      this.i.a();
      this.i = null;
    }
    if (this.h != null)
    {
      this.h.a();
      this.h = null;
    }
    this.k = null;
    this.j = null;
    this.l = null;
  }

  public class a extends b.b
  {
    public ImageView c;
    public ImageView d;
    public Button e;
    public t f;

    private a(Context arg2)
    {
      super(localContext);
      setBackgroundColor(0);
      setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
      this.f = new t(localContext);
      this.d = new ImageView(localContext);
      this.e = new Button(localContext);
      this.c = new ImageView(localContext);
      this.e.setOnClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          if (b.this.a != null)
            b.this.a.a();
        }
      });
      this.d.setClickable(true);
      this.d.setOnClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          if (b.this.b != null)
            b.this.b.a(null, null);
        }
      });
      this.f.a(this.c);
      this.f.a(this.d);
      this.f.a(this.e);
      addView(this.f, new RelativeLayout.LayoutParams(-1, -1));
    }

    private Point a(String paramString)
    {
      JSONObject localJSONObject1 = b.a(b.this).optJSONObject(paramString);
      if (localJSONObject1 != null)
      {
        JSONObject localJSONObject2 = localJSONObject1.optJSONObject("offset");
        if (localJSONObject2 != null)
          return new Point(localJSONObject2.optInt("x", 0), localJSONObject2.optInt("y", 0));
      }
      return new Point(0, 0);
    }

    protected void a(int paramInt1, int paramInt2)
    {
      boolean bool = Chartboost.sharedChartboost().orientation().isPortrait();
      a.a locala1;
      a.a locala2;
      label36: RelativeLayout.LayoutParams localLayoutParams1;
      RelativeLayout.LayoutParams localLayoutParams2;
      RelativeLayout.LayoutParams localLayoutParams3;
      float f1;
      label94: String str1;
      if (bool)
      {
        locala1 = b.this.h;
        if (!bool)
          break label567;
        locala2 = b.this.j;
        localLayoutParams1 = new RelativeLayout.LayoutParams(-2, -2);
        localLayoutParams2 = new RelativeLayout.LayoutParams(-2, -2);
        localLayoutParams3 = new RelativeLayout.LayoutParams(-2, -2);
        if (!bool)
          break label579;
        f1 = Math.max(320.0F / paramInt1, 480.0F / paramInt2);
        localLayoutParams1.width = ((int)(locala2.c() / f1));
        localLayoutParams1.height = ((int)(locala2.d() / f1));
        if (!bool)
          break label597;
        str1 = "frame-portrait";
        label132: Point localPoint1 = a(str1);
        localLayoutParams1.leftMargin = Math.round((paramInt1 - localLayoutParams1.width) / 2.0F + localPoint1.x / f1);
        localLayoutParams1.topMargin = Math.round((paramInt2 - localLayoutParams1.height) / 2.0F + localPoint1.y / f1);
        this.d.setId(100);
        localLayoutParams2.width = ((int)(locala1.c() / f1));
        localLayoutParams2.height = ((int)(locala1.d() / f1));
        if (!bool)
          break label604;
      }
      label567: label579: label597: label604: for (String str2 = "ad-portrait"; ; str2 = "ad-landscape")
      {
        Point localPoint2 = a(str2);
        localLayoutParams2.leftMargin = Math.round((paramInt1 - localLayoutParams2.width) / 2.0F + localPoint2.x / f1);
        localLayoutParams2.topMargin = Math.round((paramInt2 - localLayoutParams2.height) / 2.0F + localPoint2.y / f1);
        localLayoutParams3.width = ((int)(b.this.l.c() / f1));
        localLayoutParams3.height = ((int)(b.this.l.d() / f1));
        Point localPoint3 = a("close");
        localLayoutParams3.leftMargin = (localLayoutParams2.leftMargin + localLayoutParams2.width + Math.round(localPoint3.x / f1 - d.b(10, getContext())));
        localLayoutParams3.topMargin = (localLayoutParams2.topMargin - localLayoutParams3.height + Math.round(localPoint3.y / f1 - d.b(10, getContext())));
        this.c.setLayoutParams(localLayoutParams1);
        this.d.setLayoutParams(localLayoutParams2);
        this.e.setLayoutParams(localLayoutParams3);
        BitmapDrawable localBitmapDrawable1 = new BitmapDrawable(locala2.b());
        this.c.setScaleType(ImageView.ScaleType.FIT_CENTER);
        this.c.setImageDrawable(localBitmapDrawable1);
        BitmapDrawable localBitmapDrawable2 = new BitmapDrawable(locala1.b());
        this.d.setScaleType(ImageView.ScaleType.FIT_CENTER);
        this.d.setImageDrawable(localBitmapDrawable2);
        BitmapDrawable localBitmapDrawable3 = new BitmapDrawable(b.this.l.b());
        this.e.setBackgroundDrawable(localBitmapDrawable3);
        return;
        locala1 = b.this.i;
        break;
        locala2 = b.this.k;
        break label36;
        f1 = Math.max(320.0F / paramInt2, 480.0F / paramInt1);
        break label94;
        str1 = "frame-landscape";
        break label132;
      }
    }

    public void b()
    {
      super.b();
      this.d = null;
      this.c = null;
      this.e = null;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.chartboost.sdk.impl.b
 * JD-Core Version:    0.6.2
 */